package com.sinosoft.jwjw.component.controller.system;

import com.sinosoft.jwjw.base.BaseCrudController;
import com.sinosoft.jwjw.base.BaseCrudService;
import com.sinosoft.jwjw.component.model.system.SDataDictionaryCodeNode;
import com.sinosoft.jwjw.component.service.system.SDataDictionaryCodeNodeService;
import com.sinosoft.jwjw.utils.ConvertUtil;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/sDataDictionaryCodeNode")
public class SDataDictionaryCodeNodeController extends BaseCrudController<SDataDictionaryCodeNode,String> {

    @Autowired
   private SDataDictionaryCodeNodeService sDataDictionaryCodeNodeService;
    @Override
    public BaseCrudService<SDataDictionaryCodeNode, String> getBaseService() {
        return sDataDictionaryCodeNodeService;
    }



    @RequestMapping(value = "/queryCodeByType")
    @ResponseBody
    /**
     * @Description:  查询codeType 返回select
     * @return:  java.lang.String
     * @Author:  bankPro
     * @CreateDate:  2019/2/19 18:23
     */
    public String queryCodeByType(){
        RequestParamUtils();
        String   codeTypes  =  ConvertUtil.toString(params.get("codeTypes"));
        String [] codeArr = codeTypes.split(",");
        JSONObject jsonObject = new JSONObject();
        String codeType = "";
        String  selectStr = "";
        for (int i=0; i < codeArr.length; i++){
             codeType = codeArr[i];
            selectStr =   sDataDictionaryCodeNodeService.queryCodeByType(codeType);
            jsonObject.put(codeType,selectStr);
        }

        return jsonObject.toString();
    }
}
